/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author simone
 */
@Entity
@Table(name = "Tipo_stanza")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tipostanza.findAll", query = "SELECT t FROM Tipostanza t"),
    @NamedQuery(name = "Tipostanza.findByIdStanza", query = "SELECT t FROM Tipostanza t WHERE t.idStanza = :idStanza"),
    @NamedQuery(name = "Tipostanza.findByName", query = "SELECT t FROM Tipostanza t WHERE t.name = :name")})
public class Tipostanza implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_stanza")
    private Integer idStanza;
    @Size(max = 255)
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkStanza")
    private Collection<Pacchetto> pacchettoCollection;

    public Tipostanza() {
    }

    public Tipostanza(Integer idStanza) {
        this.idStanza = idStanza;
    }

    public Integer getIdStanza() {
        return idStanza;
    }

    public void setIdStanza(Integer idStanza) {
        this.idStanza = idStanza;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<Pacchetto> getPacchettoCollection() {
        return pacchettoCollection;
    }

    public void setPacchettoCollection(Collection<Pacchetto> pacchettoCollection) {
        this.pacchettoCollection = pacchettoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idStanza != null ? idStanza.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tipostanza)) {
            return false;
        }
        Tipostanza other = (Tipostanza) object;
        if ((this.idStanza == null && other.idStanza != null) || (this.idStanza != null && !this.idStanza.equals(other.idStanza))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.entities.Tipostanza[ idStanza=" + idStanza + " ]";
    }
    
}
